package com.derek.omeshopping.ui.home.view;

import android.content.Context;
import android.os.Bundle;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.derek.omeshopping.R;
import com.derek.omeshopping.base.BaseFragment;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by duyb on 2016-10-17.
 * Desc:首页fragment
 */

public class ShouYeFragment extends BaseFragment {
    @BindView(R.id.home_recycleview_type)
    RecyclerView homeRecycleviewType;
    @BindView(R.id.swiperefreshlayout)
    SwipeRefreshLayout swiperefreshlayout;
    private View view;
    private Context context;
    //private FragmentMainTypePresenter presenter;


    @Override
    protected void initData() {
        homeRecycleviewType.setLayoutManager(new LinearLayoutManager(context));
        //实例化 中间人对象并调用函数
        //presenter = new FragmentMainTypePresenter(this);
        // presenter.loadData(context);
    }

    @Override
    protected void initView() {
        context = getActivity();
        //设置SwipeRefreshLayout属性
        initSwipRefresh();
    }

    @Override
    public int getLayoutId() {
        return R.layout.fragment_maintab_type;
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View rootView = super.onCreateView(inflater, container, savedInstanceState);
        ButterKnife.bind(this, rootView);
        return rootView;
    }

    private void initSwipRefresh() {
        //设置刷新时动画的颜色  可以设置4个
        swiperefreshlayout.setColorSchemeResources(
                android.R.color.holo_blue_light,
                android.R.color.holo_red_light,
                android.R.color.holo_orange_light,
                android.R.color.holo_green_light
        );
        //下拉刷新
        swiperefreshlayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                // presenter.loadData(context);
                swiperefreshlayout.setRefreshing(false);
            }
        });
    }
}
